package com.zc.zby.basicframedemo.present;

import android.view.View;

import com.zc.zby.basicframedemo.adapter.ContactAdapter;
import com.zc.zby.basicframedemo.data.DataUtils;
import com.zc.zby.basicframedemo.model.UserModel;
import com.zc.zby.basicframedemo.utils.ToolUtil;

import java.util.List;

public class DataBindPresent {

    private ContactAdapter contactAdapter;

    public DataBindPresent(ContactAdapter contactAdapter) {
        this.contactAdapter = contactAdapter;
    }

    public int firstType(UserModel userModel) {
        int firstType = ToolUtil.getFirstType(ToolUtil.getFirstLetter(userModel.name.get()));
        return firstType;
    }

    public void update(View view) {
        List<UserModel> allData = contactAdapter.getAllData();
        for (int i = 0; i < allData.size(); i++) {
            UserModel userModel = allData.get(i);
            userModel.name.set(DataUtils.names2[i]);
            allData.set(i, userModel);
        }
        contactAdapter.notifyDataSetChanged();
    }
}
